package com.hbms.business.controller;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hbms.common.annotation.Log;
import com.hbms.common.core.controller.BaseController;
import com.hbms.common.core.domain.AjaxResult;
import com.hbms.common.enums.BusinessType;
import com.hbms.business.domain.HotelbmsRoomstatus;
import com.hbms.business.service.IHotelbmsRoomstatusService;
import com.hbms.common.utils.poi.ExcelUtil;
import com.hbms.common.core.page.TableDataInfo;

/**
 * 客房状态Controller
 *
 * @author zl
 * @date 2024-04-10
 */
@RestController
@RequestMapping("/business/roomstatus")
public class HotelbmsRoomstatusController extends BaseController
{
    @Autowired
    private IHotelbmsRoomstatusService hotelbmsRoomstatusService;

    /**
     * 查询客房状态列表
     */
    @PreAuthorize("@ss.hasPermi('business:roomstatus:list')")
    @GetMapping("/list")
    public AjaxResult list(HotelbmsRoomstatus hotelbmsRoomstatus)
    {
//        startPage();
        List<Map<String,Object>> list = hotelbmsRoomstatusService.selectHotelbmsRoomstatusList(hotelbmsRoomstatus);
        return AjaxResult.success(list);
    }

    /**
     * 导出客房状态列表
     */
    @PreAuthorize("@ss.hasPermi('business:roomstatus:export')")
    @Log(title = "客房状态", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HotelbmsRoomstatus hotelbmsRoomstatus)
    {
        /*List<HotelbmsRoomstatus> list = hotelbmsRoomstatusService.selectHotelbmsRoomstatusList(hotelbmsRoomstatus);
        ExcelUtil<HotelbmsRoomstatus> util = new ExcelUtil<HotelbmsRoomstatus>(HotelbmsRoomstatus.class);
        util.exportExcel(response, list, "客房状态数据");*/
        System.out.println("导出功能未完成。。。");
    }

    /**
     * 获取客房状态详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:roomstatus:query')")
    @GetMapping(value = "/{roomStatusId}")
    public AjaxResult getInfo(@PathVariable("roomStatusId") Long roomStatusId)
    {
        return success(hotelbmsRoomstatusService.selectHotelbmsRoomstatusByRoomStatusId(roomStatusId));
    }

    /**
     * 新增客房状态
     */
    @PreAuthorize("@ss.hasPermi('business:roomstatus:add')")
    @Log(title = "客房状态", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HotelbmsRoomstatus hotelbmsRoomstatus)
    {
        return toAjax(hotelbmsRoomstatusService.insertHotelbmsRoomstatus(hotelbmsRoomstatus));
    }

    /**
     * 修改客房状态
     */
    @PreAuthorize("@ss.hasPermi('business:roomstatus:edit')")
    @Log(title = "客房状态", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HotelbmsRoomstatus hotelbmsRoomstatus)
    {
        return toAjax(hotelbmsRoomstatusService.updateHotelbmsRoomstatus(hotelbmsRoomstatus));
    }

    /**
     * 删除客房状态
     */
    @PreAuthorize("@ss.hasPermi('business:roomstatus:remove')")
    @Log(title = "客房状态", businessType = BusinessType.DELETE)
    @DeleteMapping("/{roomStatusIds}")
    public AjaxResult remove(@PathVariable Long[] roomStatusIds)
    {
        return toAjax(hotelbmsRoomstatusService.deleteHotelbmsRoomstatusByRoomStatusIds(roomStatusIds));
    }
}
